#ifndef Types_First
#define Types_First
#ifdef __GNUG__
#pragma interface
#endif

//---- configuration -----------------------------------------------------------

#if defined(__GNUG__) || defined(__STDC__)
#   define ANSICPP
#endif

//--- cpp ----------------------------------------------------------------------

#ifdef ANSICPP
	// symbol concatenation operator
#   define _NAME1_(name) name
#   define _NAME2_(name1,name2) name1##name2
#   define _NAME3_(name1,name2,name3) name1##name2##name3

	// stringizing
#   define _QUOTE_(name) #name

#else

#   define _NAME1_(name) name
#   define _NAME2_(name1,name2) _NAME1_(name1)name2
#   define _NAME3_(name1,name2,name3) _NAME2_(name1,name2)name3

#   define _QUOTE_(name) "name"

#endif

//---- some useful macros ------------------------------------------------------

class _InitTermCnt {
public:
	_InitTermCnt();
	~_InitTermCnt();
};

//---- ONEXIT
#define _ONEXIT(uniquename) \
class uniquename : public _InitTermCnt { \
public: \
	uniquename() : _InitTermCnt() { } \
	~uniquename(); \
}; \
static uniquename _on_exit; \
uniquename::~uniquename()

#define ONEXIT(name) _ONEXIT(_NAME2_(_OnExit_,name))

//---- name space control ------------------------------------------------------
// the following includes automatically prefixes ET++ class names with ET_
// remove the comment to enable automatic prefixing
// MAKEDEP is defined by etmakedep in order to speed up "make depend"
//#ifndef MAKEDEP
//#include "ET_Begin.h"
//#endif

//---- types -------------------------------------------------------------------

#include "ET_stddef.h"

typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned char byte;
typedef u_int bool;
typedef u_int Rune;

typedef void (*VoidFunc)(...);
typedef int (*IntFunc)(...);
typedef void* (*VoidPtrFunc)(...);

enum HighlightState { Off, On };
enum Direction { eHor, eVert };
enum EqualType { eEqPointer, eEqValue };

//---- meta casses for builtin types ------------------------------------------

class Class;

#define SimpleMetaDef(name) \
	extern Class *_NAME2_(__isa__,name); \
	inline Class *_Type(const name*) \
		{ return _NAME2_(__isa__,name); }

//---- constants ---------------------------------------------------------------

#ifndef NULL
#   define NULL 0
#endif

#ifndef FALSE
#   define FALSE 0
#endif

#ifndef TRUE
#   define TRUE 1
#endif

const int cMaxInt   = 2147483647;
const int cMaxShort = 32767;

//---- misc --------------------------------------------------------------------

#ifdef __GNUG__
#   define SafeDelete(p) { if (p) { delete p; p= 0; } }
#   define TYPEOF(x) (typeof(*x))0
#else
#   define SafeDelete(p) { delete p; p= 0; }
#   define TYPEOF(x) *x
#endif

#define Enum(x) (*((int*)&x))
#define Bool(x) Enum(x)

//--- bit manipulation ---------------------------------------------------------

#define BIT(n)       (1 << (n))
#define SETBIT(n,i)  ((n) |= BIT(i))
#define CLRBIT(n,i)  ((n) &= ~BIT(i))
#define TESTBIT(n,i) ((bool)(((n) & BIT(i)) != 0))

#endif

